const LogModel = require('../../model/Log');
const moment = require('moment')

module.exports = {

    //获取日志列表
    getLogList: async(req, res, next) => {
        let page = parseInt(req.body.page) || 1;
        let pageSize = parseInt(req.body.pageSize) || 20;
        try {

            let Log = await LogModel
                .find()
                .skip((page - 1) * pageSize)
                .limit(pageSize)
                .exec();

            let count = await LogModel
                // .find()
                .count()
                .exec();

            let result = {}
            result.total = count
            result.currentPage = page
            result.log = Log
            result.pageSize = pageSize
            return res.ok('获取日志列表成功', result)
        } catch (e) {
            next(e)
        }
    },

};